﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace API
{
    public class InputUtils
    {
        public static bool IsDigit(String input, int minLen, int maxLen)
        {
            String pattern = @"^([0-9]*)$";
            Regex regex = new Regex(pattern);

            return regex.IsMatch(input)
                && input.Length <= maxLen
                && input.Length >= minLen;
        }

        public static bool IsEmail(String input, int minLen, int maxLen)
        {
            String pattern = @"^\w+@[a-zA-Z_]+?\.[a-zA-Z]{2,3}$";
            Regex regex = new Regex(pattern);

            return regex.IsMatch(input)
                && input.Length <= maxLen
                && input.Length >= minLen;
        }
    }
}
